

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/blog/img/favicon.png">
  <link rel="icon" type="image/png" href="/blog/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  
  <meta name="theme-color" content="#fff">
  <meta name="description" content="その時を待つよ">
  <meta name="author" content="Isshiki_Hugh">
  <meta name="keywords" content="">
  <title>report-2020牛客NOIP赛前集训营-提高组（第一场） - Isshiki&#39;sBlog</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/blog/lib/hint/hint.min.css" />

  
    
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/atom-one-dark.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_6peoq002giu.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">


<link  rel="stylesheet" href="/blog/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/blog/js/utils.js" ></script>
  <script  src="/blog/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.0.2"></head>


<body>
  <header style="height: 75vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/blog/">&nbsp;<strong>Isshiki修のBlog</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/blog/links/">
                <i class="iconfont icon-link-fill"></i>
                友链
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/blog/img/default.JPG') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2020-10-17 22:22" pubdate>
      2020年10月17日 晚上
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      2.2k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      38
       分钟
    </span>
  

  
  
    
      <!-- 不蒜子统计文章PV -->
      <span id="busuanzi_container_page_pv" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="busuanzi_value_page_pv"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">report-2020牛客NOIP赛前集训营-提高组（第一场）</h1>
            
              <p class="note note-info">
                
                  本文最后更新于：1 年前
                
              </p>
            
            <div class="markdown-body" id="post-body">
              <h2 id="T1-牛牛的方程式"><a href="#T1-牛牛的方程式" class="headerlink" title="T1 牛牛的方程式"></a>T1 牛牛的方程式</h2><p><strong><a target="_blank" rel="noopener" href="https://ac.nowcoder.com/acm/contest/7605/A">题面</a></strong></p>
<p>数学题，裴蜀定理直接做。记得分类讨论。</p>
<div class='spoiler collapsed'>
    <div class='spoiler-title'>
        code
    </div>
    <div class='spoiler-content'>
        <div class="hljs"><pre><code class="hljs cpp"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;map&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;set&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cmath&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;queue&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;bitset&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;vector&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstdio&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstring&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstdlib&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;iostream&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;algorithm&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> rep(i,a,b) for(int i = (a);i &lt;= (b);++i)</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> per(i,a,b) for(int i = (a);i &gt;= (b);--i) </span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> mkp std::make_pair</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> ll;
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> ull;
<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>;<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cin</span>;<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span>;
<span class="hljs-function"><span class="hljs-keyword">inline</span> <span class="hljs-keyword">bool</span> <span class="hljs-title">cmp</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x,<span class="hljs-keyword">int</span> y)</span></span>&#123;<span class="hljs-keyword">return</span> x &lt; y;&#125;
<span class="hljs-comment">/*use -fsanitize=undefined to debug*/</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N = <span class="hljs-number">1e6</span>+<span class="hljs-number">9</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> inf = <span class="hljs-number">1e9</span>+<span class="hljs-number">9</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">double</span> eps = <span class="hljs-number">1e-7</span>;
<span class="hljs-keyword">int</span> _;
ll a,b,c,d;

<span class="hljs-function"><span class="hljs-keyword">inline</span> ll <span class="hljs-title">gcd</span><span class="hljs-params">(ll x,ll y)</span></span>&#123;
    <span class="hljs-keyword">if</span>(!y) <span class="hljs-keyword">return</span> x;
    <span class="hljs-keyword">else</span> <span class="hljs-keyword">return</span> gcd(y,x%y);
&#125;

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span>&#123;
    <span class="hljs-built_in">std</span>::ios::sync_with_stdio(<span class="hljs-number">0</span>);<span class="hljs-built_in">cin</span>.tie(<span class="hljs-number">0</span>);<span class="hljs-built_in">cout</span>.tie(<span class="hljs-number">0</span>);
    <span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> LOCAL <span class="hljs-comment">//use &quot;g++ xxx.cpp -DLOCAL&quot;</span></span>
        freopen(<span class="hljs-string">&quot;in.in&quot;</span>, <span class="hljs-string">&quot;r&quot;</span>, <span class="hljs-built_in">stdin</span>);
    <span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
    <span class="hljs-built_in">cin</span> &gt;&gt; _;
    <span class="hljs-keyword">while</span>(_--)&#123;
        <span class="hljs-built_in">cin</span> &gt;&gt; a &gt;&gt; b &gt;&gt; c &gt;&gt; d;
        <span class="hljs-keyword">if</span>(a==b &amp;&amp; b==c &amp;&amp; a==<span class="hljs-number">0</span>)&#123;
            <span class="hljs-keyword">if</span>(d == <span class="hljs-number">0</span>) <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;YES\n&quot;</span>;
            <span class="hljs-keyword">else</span> <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;NO\n&quot;</span>;
            <span class="hljs-keyword">continue</span>;
        &#125;
        a = <span class="hljs-built_in">std</span>::<span class="hljs-built_in">abs</span>(a) , b = <span class="hljs-built_in">std</span>::<span class="hljs-built_in">abs</span>(b) , c = <span class="hljs-built_in">std</span>::<span class="hljs-built_in">abs</span>(c) , d = <span class="hljs-built_in">std</span>::<span class="hljs-built_in">abs</span>(d);
        <span class="hljs-keyword">int</span> k;
             <span class="hljs-keyword">if</span>(a==<span class="hljs-number">0</span>&amp;&amp;b==<span class="hljs-number">0</span>) k = c;
        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(a==<span class="hljs-number">0</span>&amp;&amp;c==<span class="hljs-number">0</span>) k = b;
        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(c==<span class="hljs-number">0</span>&amp;&amp;b==<span class="hljs-number">0</span>) k = a;
        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(a==<span class="hljs-number">0</span>) k = gcd(b,c);
        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(b==<span class="hljs-number">0</span>) k = gcd(a,c);
        <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(c==<span class="hljs-number">0</span>) k = gcd(a,b);
        <span class="hljs-keyword">else</span> k = gcd(c,gcd(a,b));
        <span class="hljs-keyword">if</span>(d % k &amp;&amp; d != <span class="hljs-number">0</span>) <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;NO\n&quot;</span>;
        <span class="hljs-keyword">else</span> <span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">&quot;YES\n&quot;</span>;
    &#125;
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
&#125;
</code></pre></div>

    </div>
</div>
<hr>
<h2 id="T2-牛牛的猜球游戏"><a href="#T2-牛牛的猜球游戏" class="headerlink" title="T2 牛牛的猜球游戏"></a>T2 牛牛的猜球游戏</h2><p><strong><a target="_blank" rel="noopener" href="https://ac.nowcoder.com/acm/contest/7605/B">题面</a></strong></p>
<p>记忆化+映射做的。</p>
<p>思路应该挺显然的，就是记忆化一下连续操作后的结果。</p>
<p>比如操作为：</p>
<div class="hljs"><pre><code class="hljs basic"><span class="hljs-symbol">1 </span><span class="hljs-number">2</span>
<span class="hljs-symbol">2 </span><span class="hljs-number">3</span></code></pre></div>
<p>的时候，我们可以直接记录两次操作后的数组为</p>
<div class="hljs"><pre><code class="hljs angelscript"><span class="hljs-number">1</span> <span class="hljs-number">2</span> <span class="hljs-number">0</span> <span class="hljs-number">3</span> <span class="hljs-number">4</span> <span class="hljs-number">5</span> <span class="hljs-number">6</span> <span class="hljs-number">7</span> <span class="hljs-number">8</span> <span class="hljs-number">9</span></code></pre></div>
<p>也就是可以直接存一下第 $i$ 次操作以后 $0$ ~ $9$ 序列的结果，空间是 $10^5 \times 10$ ，看起来非常正解。但是题目要求的是 $l$ ~ $r$ 的。</p>
<p>联想前缀和、线段树等，我们很容易想到要用 $1$ ~ $r$ 的结果和 $1$ ~ $(l-1)$ 的结果做一些类似于 减法 的操作。</p>
<p>即考虑记录第 $i$ 次操作的逆操作。</p>
<p>也就是假设第 $i$ 次操作后的数组是 $0$ ~ $9$ 的顺序数组，反向映射得到操作前的数组，<code>map</code>或者直接普通数组都行。</p>
<p>为什么这样可以，其实道理很简单，最初的数组和现在的数组中的元素存在一一对应的关系，不要管里面的数字的大小关系的话，实际上就是 $10$ 个不一样的符号经过若干次操作以后的某个排列顺序，把现在当成有序，那最初的就是逆操作的结果。</p>
<p>最后只需要相前缀和查询一样先把数组初始化为 $1$ ~ $(l-1)$ 的逆操作后的结果，再做一次 $1$ ~ $r$ 的操作就行了，其中 $1$ ~ $r$ 的操作中前 $1$ ~ $(l-1)$ 的操作会让数组变成 $0$ ~ $9$ 的顺序数组，之后的操作就是 $l$ ~ $r$ 的操作了。</p>
<div class='spoiler collapsed'>
    <div class='spoiler-title'>
        code
    </div>
    <div class='spoiler-content'>
        <div class="hljs"><pre><code class="hljs cpp"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;map&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;set&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cmath&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;queue&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;bitset&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;vector&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstdio&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstring&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstdlib&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;iostream&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;algorithm&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> rep(i,a,b) for(int i = (a);i &lt;= (b);++i)</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> per(i,a,b) for(int i = (a);i &gt;= (b);--i) </span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> mkp std::make_pair</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> ll;
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> ull;
<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>;<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cin</span>;<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span>;
<span class="hljs-function"><span class="hljs-keyword">inline</span> <span class="hljs-keyword">bool</span> <span class="hljs-title">cmp</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x,<span class="hljs-keyword">int</span> y)</span></span>&#123;<span class="hljs-keyword">return</span> x &lt; y;&#125;
<span class="hljs-comment">/* -fsanitize=undefined */</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N = <span class="hljs-number">1e6</span>+<span class="hljs-number">9</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> inf = <span class="hljs-number">1e9</span>+<span class="hljs-number">9</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">double</span> eps = <span class="hljs-number">1e-7</span>;
<span class="hljs-keyword">int</span> _,n,m,a[<span class="hljs-number">2</span>*N][<span class="hljs-number">15</span>],b[<span class="hljs-number">2</span>*N][<span class="hljs-number">15</span>],u,v,opt[<span class="hljs-number">2</span>*N][<span class="hljs-number">3</span>],tmp[<span class="hljs-number">15</span>],ans[<span class="hljs-number">15</span>];
<span class="hljs-keyword">int</span> <span class="hljs-built_in">map</span>[<span class="hljs-number">10</span>];
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span>&#123;
    <span class="hljs-built_in">std</span>::ios::sync_with_stdio(<span class="hljs-number">0</span>);<span class="hljs-built_in">cin</span>.tie(<span class="hljs-number">0</span>);<span class="hljs-built_in">cout</span>.tie(<span class="hljs-number">0</span>);
    <span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> LOCAL <span class="hljs-comment">//use &quot;g++ xxx.cpp -DLOCAL&quot;</span></span>
        freopen(<span class="hljs-string">&quot;in.in&quot;</span>, <span class="hljs-string">&quot;r&quot;</span>, <span class="hljs-built_in">stdin</span>);
    <span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
    <span class="hljs-built_in">cin</span> &gt;&gt; n &gt;&gt; m;
    rep(i,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>) b[<span class="hljs-number">0</span>][i] = a[<span class="hljs-number">0</span>][i] = i;
    rep(i,<span class="hljs-number">1</span>,n) <span class="hljs-built_in">cin</span> &gt;&gt; opt[i][<span class="hljs-number">1</span>] &gt;&gt; opt[i][<span class="hljs-number">2</span>];
    <span class="hljs-comment">//记忆化1~i的结果</span>
    rep(i,<span class="hljs-number">1</span>,n)&#123;
        rep(j,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>) a[i][j] = a[i<span class="hljs-number">-1</span>][j];
        u = opt[i][<span class="hljs-number">1</span>] , v = opt[i][<span class="hljs-number">2</span>];
        <span class="hljs-built_in">std</span>::swap(a[i][u],a[i][v]);
    &#125;
    <span class="hljs-comment">//推出1~i的逆操作的结果</span>
    rep(i,<span class="hljs-number">1</span>,n)&#123;
        rep(j,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>) <span class="hljs-built_in">map</span>[ a[i][j] ] = j;
        rep(j,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>) b[i][j] = <span class="hljs-built_in">map</span>[j];
    &#125;

    <span class="hljs-keyword">while</span>(m--)&#123;
        <span class="hljs-built_in">cin</span> &gt;&gt; u &gt;&gt; v;
        u--;<span class="hljs-comment">//把l变成l-1</span>
        rep(i,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>) tmp[i] = b[u][i];
        rep(i,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>) <span class="hljs-built_in">map</span>[ i ] = a[v][i];
        rep(i,<span class="hljs-number">0</span>,<span class="hljs-number">9</span>) ans[i] = tmp[ <span class="hljs-built_in">map</span>[i] ];
        rep(i,<span class="hljs-number">0</span>,<span class="hljs-number">8</span>) <span class="hljs-built_in">cout</span> &lt;&lt; ans[i] &lt;&lt; <span class="hljs-string">&quot; &quot;</span>;
        <span class="hljs-built_in">cout</span> &lt;&lt; ans[<span class="hljs-number">9</span>] &lt;&lt; <span class="hljs-string">&quot;\n&quot;</span>;
    &#125;
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
&#125;
</code></pre></div>

    </div>
</div>
<hr>
<h2 id="T3-牛牛的凑数游戏"><a href="#T3-牛牛的凑数游戏" class="headerlink" title="T3 牛牛的凑数游戏"></a>T3 牛牛的凑数游戏</h2><p><strong><a target="_blank" rel="noopener" href="https://ac.nowcoder.com/acm/contest/7605/C"> 题面</a></strong></p>
<p>做的时候还在想，这东西我似乎连暴力都不会，想想如果要枚举区间内所有可能出现的和那不是光枚举就得 $O(2^n)$  了，无力 (</p>
<p><del>赛后：<strong>我是傻逼</strong>。</del></p>
<p>首先，我们必须解决如何<strong>在多项式时间内找到这个数</strong>的问题，其他的再说。</p>
<p>为了让数据更好处理我们肯定会选择<code>sort</code>一下（升序）。然后就要利用一个<strong>类似</strong>数学归纳的思想。</p>
<ul>
<li><p><strong>有序</strong>序列长度 $n=1$ 时，答案显然，不是1就是2。</p>
</li>
<li><p>假设<strong>有序</strong>序列长度 $n=k$ 时，假设这 $k$ 个数的总和为 $sum_k$ ，且对于$l$ ~ $(k+l-1)$ 答案为 $sum_k+1$ （即1~$sum$都可以表示）。  </p>
<p>当 $n=k+1$ 时，有以下结论：</p>
<ul>
<li>① 如果对于前 $k$ 个数，存在一个前缀和大于等于 $a({k+1})$​ ，那么1~$sum_{k+1}$都是可以表示的（如果不理解就思考一下我为什么说和数归很像）</li>
<li>② 如果对于前 $k$ 个数，不存在一个前缀和大于等于 $a({k+1})$ ，即 $sum_k &lt; a({k+1})$ 那么答案就是 $sum_k+1$ </li>
</ul>
</li>
</ul>
<p>当然，只有这些还不能得到答案。有了这些结论，答案的处理应该是这样的：</p>
<ul>
<li>对于升序序列，从小往大枚举，直到出现上文结论中的②或者全部扫完</li>
<li>如果是前者，那答案就是 $sum_{k}+1$ ，如果是后者，答案就是整个 $tot+1$</li>
</ul>
<p>但是显然我们不能不停的<code>sort</code>，所以我们需要数据结构。</p>
<p>我这里使用的是用主席树，以数值为下标，在树上维护前缀和（本质上维护的是每一个数值出现的次数），类似于桶的思想，版本维护的是区间内的前缀和。维护区间内信息可以通过两棵树上的信息相互做差实现。</p>
<p><code>add</code>函数实现将数插进去并且做前缀和</p>
<div class="hljs"><pre><code class="hljs cpp"><span class="hljs-function"><span class="hljs-keyword">inline</span> <span class="hljs-keyword">void</span> <span class="hljs-title">add</span><span class="hljs-params">(<span class="hljs-keyword">int</span> las,<span class="hljs-keyword">int</span> x)</span></span>&#123;
    <span class="hljs-keyword">int</span> now = ++tot;
    sum[now] = sum[las] + x;
    per(i,<span class="hljs-number">29</span>,<span class="hljs-number">0</span>)&#123;
        <span class="hljs-keyword">if</span>(x &amp; (<span class="hljs-number">1</span>&lt;&lt;i)) ls[now] = ls[las] , rs[now] = ++tot , now = rs[now] , las = rs[las];
        <span class="hljs-keyword">else</span> rs[now] = rs[las] , ls[now] = ++tot , now = ls[now] , las = ls[las];
        sum[now] = sum[las] + x;
    &#125;
&#125;</code></pre></div>
<p><code>query</code>实现查询 $l$ ~ $r$ 之间所有小于等于 $x$ 数的和</p>
<p>（如果没有 $x$ ，则如果加出来的东西小于 $x$ 那必定做不到 $x$ ，所以答案就只能是 $sum+1$，如果有 $x$ ，那出来的必定大于等于 $x$ ，而前面的所有数都已经保证可以得到(见上文的推理) ） </p>
<div class='spoiler collapsed'>
    <div class='spoiler-title'>
        code
    </div>
    <div class='spoiler-content'>
        <div class="hljs"><pre><code class="hljs cpp"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;map&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;set&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cmath&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;queue&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;bitset&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;vector&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstdio&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstring&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;cstdlib&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;iostream&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;algorithm&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> rep(i,a,b) for(int i = (a);i &lt;= (b);++i)</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> per(i,a,b) for(int i = (a);i &gt;= (b);--i) </span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> mkp std::make_pair</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> ll;
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> ull;
<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">string</span>;<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cin</span>;<span class="hljs-keyword">using</span> <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span>;
<span class="hljs-function"><span class="hljs-keyword">inline</span> <span class="hljs-keyword">bool</span> <span class="hljs-title">cmp</span><span class="hljs-params">(<span class="hljs-keyword">int</span> x,<span class="hljs-keyword">int</span> y)</span></span>&#123;<span class="hljs-keyword">return</span> x &lt; y;&#125;
<span class="hljs-comment">/*use -fsanitize=undefined to debug*/</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> N = <span class="hljs-number">1e7</span>+<span class="hljs-number">9</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> inf = <span class="hljs-number">1e9</span>+<span class="hljs-number">9</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">double</span> eps = <span class="hljs-number">1e-7</span>;
<span class="hljs-keyword">int</span> _,n,m,p,l,r,tot;
ll sum[<span class="hljs-number">2</span>*N];
<span class="hljs-keyword">int</span> ls[<span class="hljs-number">2</span>*N],root[<span class="hljs-number">2</span>*N],rs[<span class="hljs-number">2</span>*N];

<span class="hljs-function"><span class="hljs-keyword">inline</span> <span class="hljs-keyword">void</span> <span class="hljs-title">add</span><span class="hljs-params">(<span class="hljs-keyword">int</span> las,<span class="hljs-keyword">int</span> x)</span></span>&#123;
    <span class="hljs-keyword">int</span> now = ++tot;
    sum[now] = sum[las] + x;
    per(i,<span class="hljs-number">29</span>,<span class="hljs-number">0</span>)&#123;
        <span class="hljs-keyword">if</span>(x &amp; (<span class="hljs-number">1</span>&lt;&lt;i)) ls[now] = ls[las] , rs[now] = ++tot , now = rs[now] , las = rs[las];
        <span class="hljs-keyword">else</span> rs[now] = rs[las] , ls[now] = ++tot , now = ls[now] , las = ls[las];
        sum[now] = sum[las] + x;
    &#125;
    <span class="hljs-keyword">return</span>;
&#125;

<span class="hljs-function"><span class="hljs-keyword">inline</span> ll <span class="hljs-title">query</span><span class="hljs-params">(<span class="hljs-keyword">int</span> u,<span class="hljs-keyword">int</span> v,<span class="hljs-keyword">int</span> x)</span></span>&#123;
    <span class="hljs-keyword">if</span>(x &gt;= sum[v] - sum[u] + <span class="hljs-number">1</span>) <span class="hljs-keyword">return</span> sum[v] - sum[u];
    ll ans = <span class="hljs-number">0</span>;
    per(i,<span class="hljs-number">29</span>,<span class="hljs-number">0</span>)&#123;
        <span class="hljs-keyword">if</span>(x &amp; (<span class="hljs-number">1</span>&lt;&lt;i)) ans += sum[ ls[v] ] - sum[ ls[u] ] , v = rs[v] , u = rs[u];
        <span class="hljs-keyword">else</span> v = ls[v] , u = ls[u];
    &#125;
    ans += sum[v] - sum[u];
    <span class="hljs-keyword">return</span> ans;
&#125;

<span class="hljs-function"><span class="hljs-keyword">inline</span> <span class="hljs-keyword">int</span> <span class="hljs-title">min</span><span class="hljs-params">(ll x,ll y)</span></span>&#123;<span class="hljs-keyword">if</span>(x&lt;y) <span class="hljs-keyword">return</span> x;<span class="hljs-keyword">else</span> <span class="hljs-keyword">return</span> y;&#125;

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span>&#123;
    <span class="hljs-built_in">std</span>::ios::sync_with_stdio(<span class="hljs-number">0</span>);<span class="hljs-built_in">cin</span>.tie(<span class="hljs-number">0</span>);<span class="hljs-built_in">cout</span>.tie(<span class="hljs-number">0</span>);
    <span class="hljs-meta">#<span class="hljs-meta-keyword">ifdef</span> LOCAL <span class="hljs-comment">//use &quot;g++ xxx.cpp -DLOCAL&quot;</span></span>
        freopen(<span class="hljs-string">&quot;in.in&quot;</span>, <span class="hljs-string">&quot;r&quot;</span>, <span class="hljs-built_in">stdin</span>);
    <span class="hljs-meta">#<span class="hljs-meta-keyword">endif</span></span>
    <span class="hljs-built_in">cin</span> &gt;&gt; n &gt;&gt; m;
    rep(i,<span class="hljs-number">1</span>,n)&#123;
        <span class="hljs-built_in">cin</span> &gt;&gt; p;
        root[i] = tot+<span class="hljs-number">1</span>;
        add(root[i<span class="hljs-number">-1</span>],p);
    &#125;
    ll tmp,las;
    <span class="hljs-keyword">while</span>(m--)&#123;
        <span class="hljs-built_in">cin</span> &gt;&gt; l &gt;&gt; r; --l;
        tmp = <span class="hljs-number">0</span> , las = <span class="hljs-number">-1</span>;
        <span class="hljs-keyword">while</span>(tmp != las) las = tmp , tmp = query(root[l],root[r],min(tmp+<span class="hljs-number">1</span>,inf));
        <span class="hljs-built_in">cout</span> &lt;&lt; tmp+<span class="hljs-number">1</span> &lt;&lt; <span class="hljs-string">&quot;\n&quot;</span>;
    &#125;
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
&#125;</code></pre></div>

    </div>
</div><link rel="stylesheet" href="/blog/css/spoiler.css" type="text/css"><script src="/blog/js/spoiler.js" type="text/javascript" async></script>
            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/blog/categories/%E9%A2%98%E8%A7%A3%E6%8A%A5%E5%91%8A/">题解报告</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/blog/tags/%E7%AE%97%E6%B3%95/">算法</a>
                    
                      <a class="hover-with-bg" href="/blog/tags/%E4%BF%A1%E5%A5%A5/">信奥</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">未经允许禁止用于商业用途，转载请标注出处和作者！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/blog/2020/10/22/repNC7607/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">report-2020牛客NOIP赛前集训营-提高组（第二场）</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/blog/2020/10/06/algChuSai/">
                        <span class="hidden-mobile">algorithm-初赛抱佛脚</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments">
                
                <!-- 来必力City版安装代码 -->
<div id="lv-container" data-id="city" data-uid="MTAyMC80ODI4NS8yNDc3OQ==">
  <script type="text/javascript">
     (function(d, s) {
         var j, e = d.getElementsByTagName(s)[0];
  
         if (typeof LivereTower === 'function') { return; }
  
         j = d.createElement(s);
         j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
         j.async = true;
  
         e.parentNode.insertBefore(j, e);
     })(document, 'script');
  </script>
  <noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
  </div>
  <!-- City版安装代码已完成 -->
              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->

  <div class="col-lg-7 mx-auto nopadding-md">
    <div class="container custom post-content mx-auto">
      <p><center><b>(っ*´Д`)っ㊖ <font color="darkblue">  疯 狂 暗 示  </font>(っ*´Д`)っ㊖</b></center></p><center><img src="https://pic.downk.cc/item/5f3bd3b414195aa59408fb13.png" srcset="/blog/img/loading.gif" width="50%" height="50%"/></center>
    </div>
  </div>


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  
    <!-- APlayer 音乐播放器 -->
    <div id="aplayer"></div>
    <script defer src="https://cdn.staticfile.org/aplayer/1.10.1/APlayer.min.js" ></script>
<link  rel="stylesheet" href="https://cdn.staticfile.org/aplayer/1.10.1/APlayer.min.css" />
<script type="text/javascript">
  var oldLoadAp = window.onload;
  window.onload = function () {
    oldLoadAp && oldLoadAp();

    new APlayer({
      container: document.getElementById('aplayer'),
      fixed: true,
      autoplay: 'false' === 'true',
      loop: 'all',
      order: 'random',
      theme: '#708090',
      preload: 'none',
      audio: [{"name":"SLEEPWALK","artist":"冰镇豆沙君","url":"http://music.163.com/song/media/outer/url?id=1417007045.mp3","cover":"/img/cover.jpg"},{"name":"雨き声残响","artist":"冰镇豆沙君","url":"http://music.163.com/song/media/outer/url?id=1318309030.mp3","cover":"/img/cover.jpg"},{"name":"春を告げる","artist":"茶玖","url":"http://music.163.com/song/media/outer/url?id=1460240705.mp3","cover":"/img/cover.jpg"},{"name":"ベクターフィッシュ","artist":"茶玖","url":"http://music.163.com/song/media/outer/url?id=1445572300.mp3","cover":"/img/cover.jpg"},{"name":"红莲华","artist":"噢耶","url":"http://music.163.com/song/media/outer/url?id=1397590357.mp3","cover":"/img/cover.jpg"},{"name":"横竖撇点折","artist":"噢耶","url":"http://music.163.com/song/media/outer/url?id=1421414775.mp3","cover":"/img/cover.jpg"},{"name":"たぶん","artist":"真央","url":"http://music.163.com/song/media/outer/url?id=1464762744.mp3","cover":"/img/cover.jpg"},{"name":"夜に駆ける","artist":"真央","url":"http://music.163.com/song/media/outer/url?id=1461930738.mp3","cover":"/img/cover.jpg"},{"name":"Alice","artist":"yakuri","url":"http://music.163.com/song/media/outer/url?id=1431092750.mp3","cover":"/img/cover.jpg"},{"name":"起风了","artist":"yakuri","url":"http://music.163.com/song/media/outer/url?id=1367440424.mp3","cover":"/img/cover.jpg"}]
    });
  }
</script>

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/blog/js/debouncer.js" ></script>
<script  src="/blog/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/blog/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/blog/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 6,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "report-2020牛客NOIP赛前集训营-提高组（第一场）&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 50,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>





  <script  src="/blog/js/local-search.js" ></script>
  <script>
    var path = "/blog/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>





  

  
    <!-- MathJax -->
    <script>
      MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']]
        },
        options: {
          renderActions: {
            findScript: [10, doc => {
              document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
                const display = !!node.type.match(/; *mode=display/);
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
                const text = document.createTextNode('');
                node.parentNode.replaceChild(text, node);
                math.start = { node: text, delim: '', n: 0 };
                math.end = { node: text, delim: '', n: 0 };
                doc.math.push(math);
              });
            }, '', false],
            insertedScript: [200, () => {
              document.querySelectorAll('mjx-container').forEach(node => {
                let target = node.parentNode;
                if (target.nodeName.toLowerCase() === 'li') {
                  target.parentNode.classList.add('has-jax');
                }
              });
            }, '', false]
          }
        }
      };
    </script>

    <script async src="https://cdn.staticfile.org/mathjax/3.0.5/es5/tex-svg.js" ></script>

  



  
  
    <script type="text/javascript">
      //定义获取词语下标
      var a_idx = 0;
      jQuery(document).ready(function ($) {
        //点击body时触发事件
        $("body").click(function (e) {
          //需要显示的词语
          var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善");
          //设置词语给span标签
          var $i = $("<span/>").text(a[a_idx]);
          //下标等于原来下标+1  余 词语总数
          a_idx = (a_idx + 1) % a.length;
          //获取鼠标指针的位置，分别相对于文档的左和右边缘。
          //获取x和y的指针坐标
          var x = e.pageX, y = e.pageY;
          //在鼠标的指针的位置给$i定义的span标签添加css样式
          $i.css({
            "z-index": 999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": rand_color()
          });
          // 随机颜色
          function rand_color() {
            return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
          }
          //在body添加这个标签
          $("body").append($i);
          //animate() 方法执行 CSS 属性集的自定义动画。
          //该方法通过CSS样式将元素从一个状态改变为另一个状态。CSS属性值是逐渐改变的，这样就可以创建动画效果。
          //详情请看http://www.w3school.com.cn/jquery/effect_animate.asp
          $i.animate({
            //将原来的位置向上移动180
            "top": y - 180,
            "opacity": 0
            //1500动画的速度
          }, 1500, function () {
            //时间到了自动删除
            $i.remove();
          });
        });
      })
      ;
    </script>
  














<script src="/blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/blog/live2dw/assets/assets/hijiki.model.json"},"display":{"superSample":1,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-20},"mobile":{"show":true,"scale":1},"react":{"opacityDefault":0.7,"opacityOnHover":0.2},"log":false});</script></body>
</html>
